

 function getLoginCode() {
    return new Promise((resolve, reject) => {
      uni.login({
        "provider": "weixin",
	       "onlyAuthorize": true, // 微信登录仅请求授权认证
        success: (res) => {
          if (res.code) {
            resolve(res.code)
          } else {
            reject(res)
          }
        },
        fail: (err) => {
          reject(err)
        }
      })
    })
  }

  /**
   * 
   * @returns type ParamMiniProgrammerLogin struct {
	Code     string `json:"code"`
	NickName string `json:"nickname"`
	Avatar   string `json:"avatar"`
	Gender   string `json:"gender"`
	City     string `json:"city"`
	Province string `json:"province"`
	Country  string `json:"country"`
	Language string `json:"language"`
}
   */

  export default async function wechatLogin() {
  
      let code = await getLoginCode();
      console.log("wechatLogin code:",code);
      return new Promise((resolve, reject) => {
        uni.request({
            url:`http://api.stone09.com/api/v1/login/`,
            method:"POST",
            data:{
              code:code,
            },
            success:(res)=>{
                resolve(res);
            },
    
            fail:(error)=>{
                reject(error)
            }
          })
      })
     
  }